<template>
  <div class="photoinfo-container">
    <h1 class="title">{{photoinfo.type}}</h1>
    <p class="subtitle">
      <span>发表时间：{{photoinfo.dateAdd | dataFormat}}</span>
      <span>图片ID：{{photoinfo.id}}</span>
    </p>

    <hr />

    <!-- 缩略图区域 -->
    <!-- <img
      class="preview-img"
      v-for="(item, index) in slide1"
      :src="item.src"
      height="100"
      @click="$preview.open(index, slide1)"
      :key="item.src"
    />-->
    <vue-preview :slides="slide1" @close="handleClose" class="thumbs"></vue-preview>

    <!-- 图片内容区域 -->
    <div class="content">{{photoinfo.remark}}</div>

    <!-- 评论子组件 -->
    <cmt-box :user="this.user"></cmt-box>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
// 导入子组件
import comment from "../subcomponents/comment.vue";

export default {
  data() {
    return {
      id: this.$route.params.user,
      photoinfo: [],
      slide1: []
    };
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();
  },
  methods: {
    getPhotoInfo() {
      this.$http
        .get("https://api.it120.cc/lisa/shop/goods/category/all")
        .then(result => {
          if (result.body.code === 0) {
            res = result.body.data;
            for (var i = 0; i < res.length; i++) {
              if (res[i].id == this.id) {
                this.photoinfo = res[i];
              }
            }
          } else {
            Toast("加载失败");
          }
        });
    },

    getThumbs() {
      this.slide1 = [
        {
          src:
            "https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_b.jpg",
          msrc:
            "https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg",
          alt: "picture1",
          title: "Image Caption 1",
          w: 600,
          h: 400
        },
        {
          src:
            "https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg",
          msrc:
            "https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg",
          alt: "picture2",
          title: "Image Caption 2",
          w: 1200,
          h: 900
        },
        {
          src:
            "https://farm4.staticflickr.com/3920/15008465772_383e697089_b.jpg",
          msrc:
            "https://farm4.staticflickr.com/3920/15008465772_383e697089_m.jpg",
          alt: "picture3",
          title: "Image Caption 3",
          w: 375,
          h: 281
        },
        {
          src:
            "https://farm4.staticflickr.com/3894/15008518202_b016d7d289_b.jpg",
          msrc:
            "https://farm4.staticflickr.com/3894/15008518202_b016d7d289_m.jpg",
          alt: "picture4",
          title: "Image Caption 4",
          w: 1200,
          h: 900
        }
      ];
    },

    handleClose() {
      console.log("close event");
    }
  },
  components: {
    "cmt-box": comment
  }
};
</script>

<style lang="scss" scoped>
.photoinfo-container {
  padding: 3px;
  .title {
    font-size: 15px;
    color: #26a2ff;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
}

.thumbs {
  margin: 10px;
  //   box-shadow: 0 0 8px #999;
}
</style>